package cn.iocoder.yudao.module.crossborder.risk.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.RiskAssessmentDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.RiskAssessmentReqDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.FraudDetectionDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.ComplianceCheckDTO;
import cn.iocoder.yudao.module.crossborder.risk.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 风险管理 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 风险管理")
public interface RiskApi {

    String PREFIX = ApiConstants.PREFIX + "/risk";

    @PostMapping(PREFIX + "/assessment")
    @Operation(summary = "风险评估")
    CommonResult<RiskAssessmentDTO> assessRisk(@RequestBody @Valid RiskAssessmentReqDTO assessmentReq);

    @GetMapping(PREFIX + "/assessment/get")
    @Operation(summary = "获得风险评估记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<RiskAssessmentDTO> getRiskAssessment(@RequestParam("id") @NotNull Long id);

    @PostMapping(PREFIX + "/fraud/detect")
    @Operation(summary = "欺诈检测")
    @Parameter(name = "userId", description = "用户编号", required = true, example = "1024")
    @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048")
    CommonResult<FraudDetectionDTO> detectFraud(@RequestParam("userId") @NotNull Long userId,
                                               @RequestParam("orderId") @NotNull Long orderId);

    @PostMapping(PREFIX + "/compliance/check")
    @Operation(summary = "合规检查")
    @Parameter(name = "businessType", description = "业务类型", required = true, example = "ORDER")
    @Parameter(name = "businessId", description = "业务编号", required = true, example = "1024")
    CommonResult<ComplianceCheckDTO> checkCompliance(@RequestParam("businessType") @NotNull String businessType,
                                                    @RequestParam("businessId") @NotNull Long businessId);

    @PostMapping(PREFIX + "/blacklist/add")
    @Operation(summary = "添加黑名单")
    @Parameter(name = "type", description = "类型", required = true, example = "USER")
    @Parameter(name = "value", description = "值", required = true, example = "user123")
    @Parameter(name = "reason", description = "原因", required = true, example = "欺诈行为")
    CommonResult<Boolean> addBlacklist(@RequestParam("type") @NotNull String type,
                                      @RequestParam("value") @NotNull String value,
                                      @RequestParam("reason") @NotNull String reason);

    @PostMapping(PREFIX + "/blacklist/remove")
    @Operation(summary = "移除黑名单")
    @Parameter(name = "type", description = "类型", required = true, example = "USER")
    @Parameter(name = "value", description = "值", required = true, example = "user123")
    CommonResult<Boolean> removeBlacklist(@RequestParam("type") @NotNull String type,
                                         @RequestParam("value") @NotNull String value);

    @GetMapping(PREFIX + "/blacklist/check")
    @Operation(summary = "检查黑名单")
    @Parameter(name = "type", description = "类型", required = true, example = "USER")
    @Parameter(name = "value", description = "值", required = true, example = "user123")
    CommonResult<Boolean> checkBlacklist(@RequestParam("type") @NotNull String type,
                                        @RequestParam("value") @NotNull String value);

}
